﻿//
//  Banner (TEMPLATE)
//
//  Created by Andy Hatch on 2008-06-30.
//

import com.hatch.video.SimplePRVid;
import mx.utils.Delegate;
import PointRollAPI.PointRoll;

class com.companyName.Banner
{	
	private var _view:MovieClip;
	private var _me;
	private var _video:SimplePRVid;
	private var _prControl:PointRoll;
	
	function Banner(view:MovieClip)
	{
		_view = view;
		_me = this;
		
		initialize();
	}
	
	private function initialize():Void
	{
		trace(_view);
		_prControl = new PointRoll(_view);
		
		//EXAMPLE VIDEO + ROLLOVER SETUP
		var vidFolder:String = "Kellogs";	//points to folder on PointRoll server
		var vidFiles:Array = ["invite_intro_2_8_700K"];
		var vidLengths:Array = [""]; //lengths not required
		
		_video = new SimplePRVid(_view, _view.spVideoMC.bufferingLoader_mc, _view.spVideoMC.SP_video, vidFolder, vidFiles, vidLengths);
		
		_view.hitArea.onRollOver = Delegate.create(this, onBannerRollOver);
		
		//begin with playing video
		_video.playVideo(0);

	}
	
		/*
		*
	PUBLIC METHODS
		*
		*/

		//


		/*
		*
	PRIVATE METHODS
		*
		*/
	
	private function expand():Void
	{
		_video.killVideo();
		_prControl.openPanel(1);	
	}
	
	private function configureVideo():Void
	{
		//listen for complete
		var listener:Object = new Object();
		
		listener.videoComplete = Delegate.create(_me, onVideoComplete);
		listener.videoFail = Delegate.create(_me, onVideoFail);
		
		_video.addEventListener("videoComplete", listener);
		_video.addEventListener("videoFail", listener);
	}
	
		/*
		*
	HANDLERS
		*
		*/
	
	private function onBannerRollOver():Void
	{
		expand();
	}
	
	private function onVideoFail():Void
	{
		_video.playVideo(0);
	}
	
	private function onVideoComplete():Void
	{
		//
	}
}